﻿using UnityEngine;
using System.Collections;
using System.Xml;
public class MoverMissile : Mover
{
    public enum MissileType 
    {
      Line = 0,
    }
    MissileType missileType;
    public float MoveSpeed;
    public enum RotationType 
    {
        Forward,  //像前.
        LookAtTarget,
    } 
    RotationType rotationType;

    public override void Init(XmlNode node)
    {
        if (node.Attributes["Speed"] != null) 
        {
            this.MoveSpeed = float.Parse( node.Attributes["Speed"].Value );
        }
        if (node.Attributes["MissileType"] != null) 
        {
            this.missileType = (MissileType)System.Enum.Parse(typeof(MissileType), node.Attributes["MissileType"].Value,true);
        }
        if (node.Attributes["RotationType"] != null)
        {
            this.rotationType = (RotationType)System.Enum.Parse(typeof(RotationType), node.Attributes["RotationType"].Value, true);
        }
    }
    public override void UpdateMove()
    {
        switch (missileType) 
        {
            case MissileType.Line:
                _UpdateLineMove();
            break;
        }
    }

    public void _UpdateLineMove() 
    {
        switch (this.rotationType) 
        {
           case RotationType.Forward:
             transform.localPosition += Vector3.up * MoveSpeed * Time.deltaTime;
           break;
        }
    }
}
